package com.glory.brepda.adapter;

import android.widget.CheckBox;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.brepda.R;
import com.glory.brepda.entity.ChangeShiftEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * FileName: ChangeShiftsAdapter
 * Author: XJH
 * Date: 2020/7/1 19:31
 * Description:
 * History:
 */
public class ChangeShiftsTestAdapter extends BaseQuickAdapter<ChangeShiftEntity.ChangeShift, BaseViewHolder> {

    public List<ChangeShiftEntity.ChangeShift> deleteData;

    public ChangeShiftsTestAdapter(@Nullable List<ChangeShiftEntity.ChangeShift> data) {
        super(R.layout.item_change_shift_test_adapter,data);
        deleteData = new ArrayList<>();
    }

    @Override
    protected void convert(BaseViewHolder helper, ChangeShiftEntity.ChangeShift item) {
        helper.setText(R.id.tvLotNum,item.getLOTID())
                .setText(R.id.tvNo,String.valueOf(helper.getAdapterPosition() + 1))
                .setText(R.id.tvFinishNum,item.getMEASUREDQTY())
                .setText(R.id.tvSurplusNum,item.getRETESTQTY())
                .setText(R.id.tvUser,item.getTECHNICIAN())
                .setText(R.id.tvClassType,item.getCLASSTYPE())
                .setText(R.id.tvComment,item.getREMARKS())
                .setText(R.id.tvEqpID,item.getEQUIPMENTID());

        CheckBox checkbox = helper.getView(R.id.checkbox);
        checkbox.setChecked(false);
        checkbox.setOnCheckedChangeListener((compoundButton, b) -> {
            if (b){
                deleteData.add(item);
            }else {
                deleteData.remove(item);
            }
        });

    }

}
